<%@ page import="bean.Rooms" %>
<%@ page import="java.sql.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改房间信息</title>
    <style type="text/css">
        h1 {
            text-align: center;
        }

        h4 {
            text-align: center;
            color: red;
        }

        body {
            background-color: rgba(206, 192, 192, 0.1);
        }

        div {
            text-align: center;
        }
        label {
            width: 100px;
            text-align: right;
            display: inline-block;
        }
    </style>
</head>
<body>

<%-- 头部 --%>
<h1>修改房间信息</h1>
<hr/>
<%!String roomID;
    String roomType=null;
    String roomSize=null;
    String price=null;
    String roomCondition=null;
    String roomName=null;
//    String roomConditiof=null;
%>
<%
    //获取admin-home.jsp页面的bookid
     roomID = request.getParameter("roomID");
     roomID=roomID.replace("\"","");
    Connection con=null;
    Statement sql;
    ResultSet rs;
//    Context context=new InitialContext();
//    Context contextNeeded =(Context) context.lookup("java:comp/env");
//    DataSource ds=(DataSource) contextNeeded.lookup("hotelConn");
    String driver="org.mariadb.jdbc.Driver";
    String url="jdbc:mariadb://localhost:3306/hotel-management-system";
    try {
        Class.forName(driver);
        con= DriverManager.getConnection(url,"root","123456");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    try {
        assert con != null;
        sql=con.createStatement();
        //读取酒店详情表
        String ex="select * from rooms where RoomID='"+roomID+"' ";
        rs=sql.executeQuery(ex);
        while (rs.next()){
            roomID=rs.getString("RoomID");
            roomName=rs.getString("RoomName");
            roomCondition=rs.getString("RoomCondi");
            if (roomCondition.equals("1")){
                roomCondition="未预定";
            }else if (roomCondition.equals("0")){
                roomCondition="已预定";
            }
            roomSize=rs.getString("RoomSize");
            roomType=rs.getString("RoomType");
            price=rs.getString("Price");
        }
    }catch (SQLException e){
        System.out.print(e);
    }
    finally {
        try {
            assert con != null;
            con.close();
        }catch (Exception e){
            System.out.print(e);

        }
    }

%>

<form action="admin-Update" method="post" >
    <div>
        <tr>
            <label>房号：</label>
            <input type="text" name="RoomID" id="RoomID" value="<%=roomID%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>房间名称：</label>
            <input type="text" name="RoomName" id="RoomName" value="<%=roomName%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>房型：</label>
            <input type="text" name="RoomType" id="RoomType" value="<%=roomType%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>房价：</label></td>
            <input type="text" name="Price" id="Price" value="<%=price%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>面积：</label>
            <input type="text" name=RoomSize id="RoomSize" value="<%=roomSize%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>预定情况：</label>
            <input type="radio" name="RoomCondi"  value="未预定" checked="ok"/>未预定
            <input type="radio" name="RoomCondi" value="已预定" >已预定
        </tr>
    </div>
    <div>
        <tr>
            <input type="submit" value="确定修改">
        </tr>
<%--    </div>--%>
    </div>
</form>
</body>
</html>
